package com.cuit.lotery.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.cuit.lotery.entity.Winners;
import com.cuit.lotery.mapper.WinnersMapper;
import com.cuit.lotery.service.WinnersService;
import com.mysql.cj.Query;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Collections;
import java.util.List;

@Service
public class WinnersServiceImpl implements WinnersService {
    @Autowired
    private WinnersMapper mapper;
    @Override
    public Integer insert(Winners data) {
        return mapper.insert(data);
    }

    @Override
    public Winners getOne(String key, Object val) {
        return mapper.selectOne(new QueryWrapper<Winners>()
                .eq(key, val));
    }

    @Override
    public List<Winners> getAll() {
        return mapper.selectList(new QueryWrapper<Winners>().orderByDesc("rd_date"));
    }

    @Override
    public List<Winners> getTop10() {
        return mapper.selectList(new QueryWrapper<Winners>().orderByDesc("rd_date").last("limit 10"));
    }
}
